package com.ddxz.tool.web.common;

import com.alibaba.fastjson.JSONObject;
import com.ddxz.tool.web.dto.DdxzResponse;

import static com.ddxz.tool.web.common.ConstData.KEY_STATUS;
import static com.ddxz.tool.web.common.ConstData.OK_STATUS;

/**
 * description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/6/12
 */
public class HttpUtil {
    public static boolean isSuccess(DdxzResponse response) {
        if(null == response) {
            return false;
        }

        return OK_STATUS == response.getStatus();
    }

    public static boolean isSuccess(JSONObject rst) {
        if(null == rst) {
            return false;
        }

        if(!rst.containsKey(KEY_STATUS)) {
            return false;
        }

        return OK_STATUS == rst.getInteger(KEY_STATUS);
    }
}
